share skip list between triggers

Hi all!

I'm trying to share a skip list between a post-open and a pre-close trigger, without any success....i already try to explore the evalTop_ and the addr_ functions, but my knowledge concerning these two are not enough. :(

Does anyone have made this or can point me the way to achieve this?

Thanks in advance
mgomes - Wed Jun 16 18:33:54 EDT 2010

Re: share skip list between triggers
Mathias Mamsch - Thu Jun 17 09:52:05 EDT 2010

Since each trigger has its own DXL context you need to use a global variable. Use evalTop_ to install it and noerror(); eval_ ("myGlobVar"); if (!null lastError) to check its existence. You might need to have a third trigger with a very high priority to install the var before the other two triggers are called, since evalTop_ will only run after your trigger finished. Once you installed the global var you should be able to use it in both triggers. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: share skip list between triggers
mgomes - Thu Jun 17 11:29:27 EDT 2010

Mathias Mamsch - Thu Jun 17 09:52:05 EDT 2010
Since each trigger has its own DXL context you need to use a global variable. Use evalTop_ to install it and noerror(); eval_ ("myGlobVar"); if (!null lastError) to check its existence. You might need to have a third trigger with a very high priority to install the var before the other two triggers are called, since evalTop_ will only run after your trigger finished. Once you installed the global var you should be able to use it in both triggers. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

These are the triggers that i have created:

Trigger t0 = trigger("installGlobalVariables", 
                     project->module->all->formal, 
                     pre, 
                     open, 
                     0, 
                     "#include <Triggers/_ag_install_global_variables.dxl>")
 
 
Trigger t1 = trigger("modPostOpen", 
                     project->module->all->formal, 
                     post, 
                     open, 
                     5, 
                     "#include <Triggers/_ag_store_public_views.dxl>")
 
Trigger t2 = trigger("modPreClose", 
                     project->module->all->formal, 
                     pre, 
                     close, 
                     5, 
                     "#include <Triggers/_ag_apply_private_views.dxl>")

 


On the higher trigger as you proposed i installed the global var:

 

 

//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled) evalTop_ ("Skip ag_gskpPublicViews = create()")



On the post open, i fill the values:
not all the code is here, only relevant part



 

 

string viewName = ""
string strViewFullName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
    
    strViewFullName = name(parentProject)"_"name(ag_post_open_module)"_"viewName""
    if (!find(ag_gskpPublicViews,strViewFullName)) put(ag_gskpPublicViews,strViewFullName,strViewFullName)
}



On the pre close, i check the values:
not all the code is here, only relevant part



 

 

// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    strViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName""
    if (find(ag_gskpPublicViews,strViewFullName))
    {
        delete(ag_gskpPublicViews,strViewFullName)
    }  
    else
    {
        //load view v
        
        //ViewDef vDef = createPrivate(ag_pre_close_module,true)
        //save (myView,vDef)
        //save ag_pre_close_module
        
        print strViewFullName"\n"
    }    
}



The result, is that nothing is found on the skip list, and i do not know why!! Could you please check if is missing any check or I'm accessing wrongly the global skip!?



 

Re: share skip list between triggers
mgomes - Thu Jun 17 11:30:00 EDT 2010

Mathias Mamsch - Thu Jun 17 09:52:05 EDT 2010
Since each trigger has its own DXL context you need to use a global variable. Use evalTop_ to install it and noerror(); eval_ ("myGlobVar"); if (!null lastError) to check its existence. You might need to have a third trigger with a very high priority to install the var before the other two triggers are called, since evalTop_ will only run after your trigger finished. Once you installed the global var you should be able to use it in both triggers. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

These are the triggers that i have created:

Trigger t0 = trigger("installGlobalVariables", 
                     project->module->all->formal, 
                     pre, 
                     open, 
                     0, 
                     "#include <Triggers/_ag_install_global_variables.dxl>")
 
 
Trigger t1 = trigger("modPostOpen", 
                     project->module->all->formal, 
                     post, 
                     open, 
                     5, 
                     "#include <Triggers/_ag_store_public_views.dxl>")
 
Trigger t2 = trigger("modPreClose", 
                     project->module->all->formal, 
                     pre, 
                     close, 
                     5, 
                     "#include <Triggers/_ag_apply_private_views.dxl>")

 


On the higher trigger as you proposed i installed the global var:

 

 

//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled) evalTop_ ("Skip ag_gskpPublicViews = create()")



On the post open, i fill the values:
not all the code is here, only relevant part



 

 

string viewName = ""
string strViewFullName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
    
    strViewFullName = name(parentProject)"_"name(ag_post_open_module)"_"viewName""
    if (!find(ag_gskpPublicViews,strViewFullName)) put(ag_gskpPublicViews,strViewFullName,strViewFullName)
}



On the pre close, i check the values:
not all the code is here, only relevant part



 

 

// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    strViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName""
    if (find(ag_gskpPublicViews,strViewFullName))
    {
        delete(ag_gskpPublicViews,strViewFullName)
    }  
    else
    {
        //load view v
        
        //ViewDef vDef = createPrivate(ag_pre_close_module,true)
        //save (myView,vDef)
        //save ag_pre_close_module
        
        print strViewFullName"\n"
    }    
}



The result, is that nothing is found on the skip list, and i do not know why!! Could you please check if is missing any check or I'm accessing wrongly the global skip!?



 

Re: share skip list between triggers
Mathias Mamsch - Thu Jun 17 12:25:28 EDT 2010

mgomes - Thu Jun 17 11:30:00 EDT 2010

These are the triggers that i have created:

Trigger t0 = trigger("installGlobalVariables", 
                     project->module->all->formal, 
                     pre, 
                     open, 
                     0, 
                     "#include <Triggers/_ag_install_global_variables.dxl>")
 
 
Trigger t1 = trigger("modPostOpen", 
                     project->module->all->formal, 
                     post, 
                     open, 
                     5, 
                     "#include <Triggers/_ag_store_public_views.dxl>")
 
Trigger t2 = trigger("modPreClose", 
                     project->module->all->formal, 
                     pre, 
                     close, 
                     5, 
                     "#include <Triggers/_ag_apply_private_views.dxl>")

 


On the higher trigger as you proposed i installed the global var:

 

 

//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled) evalTop_ ("Skip ag_gskpPublicViews = create()")



On the post open, i fill the values:
not all the code is here, only relevant part



 

 

string viewName = ""
string strViewFullName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
    
    strViewFullName = name(parentProject)"_"name(ag_post_open_module)"_"viewName""
    if (!find(ag_gskpPublicViews,strViewFullName)) put(ag_gskpPublicViews,strViewFullName,strViewFullName)
}



On the pre close, i check the values:
not all the code is here, only relevant part



 

 

// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    strViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName""
    if (find(ag_gskpPublicViews,strViewFullName))
    {
        delete(ag_gskpPublicViews,strViewFullName)
    }  
    else
    {
        //load view v
        
        //ViewDef vDef = createPrivate(ag_pre_close_module,true)
        //save (myView,vDef)
        //save ag_pre_close_module
        
        print strViewFullName"\n"
    }    
}



The result, is that nothing is found on the skip list, and i do not know why!! Could you please check if is missing any check or I'm accessing wrongly the global skip!?



 

If I apply your code to a test module, but replacing the trigger code of the open triggers by the following, then this works. I would suggest you insert some print statements to see, if there is really something put into the Skip list.

My guess is that maybe your module handle might not be ok. Did you set this var the right way?
 

Module ag_post_open_module = module current Trigger

 


Regards, Mathias

 

 

 

// _ag_apply_private_views.dxl
print "Apply private Views Trigger\n"
 
int n = -1
string m = ""
 
if (!find(ag_gskpPublicViews, 1, n)) print "1 not found ...\n"
if (!find(ag_gskpPublicViews, 2, m)) print "2 not found ...\n"
 
print "n = " n " m = " m "\n"

 

 

 

 

// _ag_store_public_views.dxl
print "Store Public Views Trigger\n"
 
put(ag_gskpPublicViews, 1, 10)
put(ag_gskpPublicViews, 2, "a string")

 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: share skip list between triggers
mgomes - Thu Jun 17 12:48:08 EDT 2010

Mathias Mamsch - Thu Jun 17 09:52:05 EDT 2010
Since each trigger has its own DXL context you need to use a global variable. Use evalTop_ to install it and noerror(); eval_ ("myGlobVar"); if (!null lastError) to check its existence. You might need to have a third trigger with a very high priority to install the var before the other two triggers are called, since evalTop_ will only run after your trigger finished. Once you installed the global var you should be able to use it in both triggers. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

These are the triggers that i have created:

Trigger t0 = trigger("installGlobalVariables", 
                     project->module->all->formal, 
                     pre, 
                     open, 
                     0, 
                     "#include <Triggers/_ag_install_global_variables.dxl>")
 
 
Trigger t1 = trigger("modPostOpen", 
                     project->module->all->formal, 
                     post, 
                     open, 
                     5, 
                     "#include <Triggers/_ag_store_public_views.dxl>")
 
Trigger t2 = trigger("modPreClose", 
                     project->module->all->formal, 
                     pre, 
                     close, 
                     5, 
                     "#include <Triggers/_ag_apply_private_views.dxl>")

 


On the higher trigger as you proposed i installed the global var:

 

 

//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled) evalTop_ ("Skip ag_gskpPublicViews = create()")



On the post open, i fill the values:
not all the code is here, only relevant part



 

 

string viewName = ""
string strViewFullName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
    
    strViewFullName = name(parentProject)"_"name(ag_post_open_module)"_"viewName""
    if (!find(ag_gskpPublicViews,strViewFullName)) put(ag_gskpPublicViews,strViewFullName,strViewFullName)
}



On the pre close, i check the values:
not all the code is here, only relevant part



 

 

// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    strViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName""
    if (find(ag_gskpPublicViews,strViewFullName))
    {
        delete(ag_gskpPublicViews,strViewFullName)
    }  
    else
    {
        //load view v
        
        //ViewDef vDef = createPrivate(ag_pre_close_module,true)
        //save (myView,vDef)
        //save ag_pre_close_module
        
        print strViewFullName"\n"
    }    
}



The result, is that nothing is found on the skip list, and i do not know why!! Could you please check if is missing any check or I'm accessing wrongly the global skip!?



 

Re: share skip list between triggers
Mathias Mamsch - Thu Jun 17 16:11:27 EDT 2010

mgomes - Thu Jun 17 12:48:08 EDT 2010

These are the triggers that i have created:

Trigger t0 = trigger("installGlobalVariables", 
                     project->module->all->formal, 
                     pre, 
                     open, 
                     0, 
                     "#include <Triggers/_ag_install_global_variables.dxl>")
 
 
Trigger t1 = trigger("modPostOpen", 
                     project->module->all->formal, 
                     post, 
                     open, 
                     5, 
                     "#include <Triggers/_ag_store_public_views.dxl>")
 
Trigger t2 = trigger("modPreClose", 
                     project->module->all->formal, 
                     pre, 
                     close, 
                     5, 
                     "#include <Triggers/_ag_apply_private_views.dxl>")

 


On the higher trigger as you proposed i installed the global var:

 

 

//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled) evalTop_ ("Skip ag_gskpPublicViews = create()")



On the post open, i fill the values:
not all the code is here, only relevant part



 

 

string viewName = ""
string strViewFullName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
    
    strViewFullName = name(parentProject)"_"name(ag_post_open_module)"_"viewName""
    if (!find(ag_gskpPublicViews,strViewFullName)) put(ag_gskpPublicViews,strViewFullName,strViewFullName)
}



On the pre close, i check the values:
not all the code is here, only relevant part



 

 

// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    strViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName""
    if (find(ag_gskpPublicViews,strViewFullName))
    {
        delete(ag_gskpPublicViews,strViewFullName)
    }  
    else
    {
        //load view v
        
        //ViewDef vDef = createPrivate(ag_pre_close_module,true)
        //save (myView,vDef)
        //save ag_pre_close_module
        
        print strViewFullName"\n"
    }    
}



The result, is that nothing is found on the skip list, and i do not know why!! Could you please check if is missing any check or I'm accessing wrongly the global skip!?



 

Dude, posting the code a third time does still not enable me to tell you why your skip list is empty. You need to put a +print "I AM PUTTING STUFF IN THE GLOBAL SKIP" + statement in front of your put statement to see, if there is something put into the skip.

It could have a lot of reasons why you don't get any value in the skip:
a) your module handle is bs -> you did not post the part of the code where you acquire the module handle, so I cannot tell
b) Your ag_Function_isPrivateView is bs -> if it returns true always you will not have anything in the skips -> but you did not post the code
c) your current module is somehow not equal to the trigger module, therefore your view() call gives you nothing -> oh wait! You did not post the relevant code.

So how should anyone tell what is going wrong in your code??

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: share skip list between triggers
mgomes - Thu Jun 17 18:02:56 EDT 2010

Mathias Mamsch - Thu Jun 17 12:25:28 EDT 2010

If I apply your code to a test module, but replacing the trigger code of the open triggers by the following, then this works. I would suggest you insert some print statements to see, if there is really something put into the Skip list.

My guess is that maybe your module handle might not be ok. Did you set this var the right way?
 

Module ag_post_open_module = module current Trigger

 


Regards, Mathias

 

 

 

// _ag_apply_private_views.dxl
print "Apply private Views Trigger\n"
 
int n = -1
string m = ""
 
if (!find(ag_gskpPublicViews, 1, n)) print "1 not found ...\n"
if (!find(ag_gskpPublicViews, 2, m)) print "2 not found ...\n"
 
print "n = " n " m = " m "\n"

 

 

 

 

// _ag_store_public_views.dxl
print "Store Public Views Trigger\n"
 
put(ag_gskpPublicViews, 1, 10)
put(ag_gskpPublicViews, 2, "a string")

 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Hi!

I found my error. Since i'm using a string variable to insert the values to the skip list, that string must be also global or else when the trigger is ended it will lose all the values.

Thanks a lot for help me finding a solution, i'm trying to implement this in the last 3 days... next time i will ask for help here sooner...

One more time thanks

Re: share skip list between triggers
mgomes - Thu Jun 17 18:04:45 EDT 2010

Mathias Mamsch - Thu Jun 17 16:11:27 EDT 2010
Dude, posting the code a third time does still not enable me to tell you why your skip list is empty. You need to put a +print "I AM PUTTING STUFF IN THE GLOBAL SKIP" + statement in front of your put statement to see, if there is something put into the skip.

It could have a lot of reasons why you don't get any value in the skip:
a) your module handle is bs -> you did not post the part of the code where you acquire the module handle, so I cannot tell
b) Your ag_Function_isPrivateView is bs -> if it returns true always you will not have anything in the skips -> but you did not post the code
c) your current module is somehow not equal to the trigger module, therefore your view() call gives you nothing -> oh wait! You did not post the relevant code.

So how should anyone tell what is going wrong in your code??

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

The first time that i reply to you it send twices the message. Sorry for that!

Re: share skip list between triggers
Mathias Mamsch - Thu Jun 17 18:45:52 EDT 2010

mgomes - Thu Jun 17 18:04:45 EDT 2010
The first time that i reply to you it send twices the message. Sorry for that!

No problem :-) You might want to send the relevant part of the code though, so maybe we can still find out what is wrong. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: share skip list between triggers
mgomes - Thu Jun 17 19:51:54 EDT 2010

Mathias Mamsch - Thu Jun 17 18:45:52 EDT 2010
No problem :-) You might want to send the relevant part of the code though, so maybe we can still find out what is wrong. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

The code that works is below:

file: _ag_install_global_variables.dxl
//Skip list used to prevent the creation of public views not defined in datamodel
noError()
eval_ "ag_gskpPublicViews; return_ \"\"" 
string notInstalled = lastError() 
if (!null notInstalled)
{
    evalTop_ ("Skip ag_gskpPublicViews = create()")
    evalTop_ ("string ag_gstrViewFullName = \"\"")
}
 
file: _ag_store_public_views.dxl
 
Module ag_post_open_module = module current Trigger
Project parentProject = getParentProject(ag_post_open_module)
string viewName = ""
 
// For all views in the current module...
for viewName in views ( ag_post_open_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        // if the handle is null.
        continue
    }
 
    ag_gstrViewFullName= name(parentProject)"_"name(ag_post_open_module)"_"viewName
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        if (find(ag_gskpPublicViews, ag_gstrViewFullName))
        {
            delete(ag_gskpPublicViews,ag_gstrViewFullName)
        }            
    }
    else
    {
        if (!find (ag_gskpPublicViews, ag_gstrViewFullName))
        {
            put(ag_gskpPublicViews,ag_gstrViewFullName,ag_gstrViewFullName)
        }
    }    
}
 
file: _ag_apply_private_views.dxl
 
Module ag_pre_close_module = module current Trigger
Project parentProject = getParentProject(ag_pre_close_module)
string viewName = ""
 
// For all views in the current module...
for viewName in views ( ag_pre_close_module ) do
{
    // Get the view.
    View myView = view (viewName)
 
    if (null myView)
    {
        //  if the handle is null.
        continue
    }
 
    // If the views is private do nothing... only consider public views for the data model.
    if (ag_Function_isPrivateView(myView))
    {
        continue
    }
 
    ag_gstrViewFullName = name(parentProject)"_"name(ag_pre_close_module)"_"viewName
    if (find(ag_gskpPublicViews,ag_gstrViewFullName))
    {
        delete(ag_gskpPublicViews,ag_gstrViewFullName)
    }  
    else
    {
        load view viewName
        
        ViewDef vDef = createPrivate(ag_pre_close_module,true)
        save (myView,vDef)
        save ag_pre_close_module
    }    
}

 


like this i have finished and is correct with your help
thanks